package javadany03;

public class Shell {
	public static void main(String[] args) {
        int[] arr = {6,8,2,1,5,9,6,3,7};
        int gap = arr.length;
        sort(arr, gap);
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]+" ");
        }
    }
 
    public static void sort(int[] arr, int gap) {
        gap = gap / 2;
        for (int i = 0; i < gap; i++) {
            for (int j = i + gap; j < arr.length; j += gap) {
                int current = arr[j];
                for (int k = j - gap; k >= i; k -= gap) {
                    if (arr[k] > current) {
                        arr[k + gap] = arr[k];
                        arr[k] = current;
                    }
                }
            }
        }
 
        if (gap > 1) {
            sort(arr, gap);
        }
    }
                      
}
